package pers.wq.model.dao.core;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {
	private static Configuration configuration;
	private static SessionFactory seesionFactory;
	static {
		configuration = new Configuration().configure();
	}
	public synchronized static SessionFactory getSessionFactory() {
		if(null == seesionFactory || seesionFactory.isClosed()) {
			seesionFactory = configuration.buildSessionFactory();
		}
		return seesionFactory;
	}
	public synchronized static Session getSession() {
		return getSessionFactory().openSession();
	}
}
